﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using DAL;
using System.Text;

/// <summary>
///EPioneerData 的摘要说明
/// </summary>
public class EPioneerDataDAL
{
    public EPioneerDataDAL()
    {
        //
        //TODO: 在此处添加构造函数逻辑
        //
    }

    delegate DataSet EPioneerDS(string connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters);
    EPioneerDS instance = new EPioneerDS(SqlHelper.ExecuteGetDataSet);
    /// <summary>
    /// 获取单条信息
    /// </summary>
    /// <param name="type1"></param>
    /// <param name="type2"></param>
    /// <param name="type3"></param>
    /// <param name="type4"></param>
    /// <param name="type5"></param>
    /// <param name="count1"></param>
    /// <param name="count2"></param>
    /// <param name="count3"></param>
    /// <param name="count4"></param>
    /// <param name="count5"></param>
    /// <param name="sign"></param>
    /// <returns></returns>
    public List<EPioneerDataModel> GetNewsName(int type1, int type2, int type3, int type4, int type5, int count1, int count2, int count3, int count4, int count5, int sign)
    {
        List<EPioneerDataModel> list = new List<EPioneerDataModel>();
        Tools tool = new Tools();
        tool.AddSqlParameter("type1", SqlDbType.Int, type1);
        tool.AddSqlParameter("type2", SqlDbType.Int, type2);
        tool.AddSqlParameter("type3", SqlDbType.Int, type3);
        tool.AddSqlParameter("type4", SqlDbType.Int, type4);
        tool.AddSqlParameter("type5", SqlDbType.Int, type5);
        tool.AddSqlParameter("count1", SqlDbType.Int, count1);
        tool.AddSqlParameter("count2", SqlDbType.Int, count2);
        tool.AddSqlParameter("count3", SqlDbType.Int, count3);
        tool.AddSqlParameter("count4", SqlDbType.Int, count4);
        tool.AddSqlParameter("count5", SqlDbType.Int, count5);
        tool.AddSqlParameter("sign", SqlDbType.Int, sign);
        try
        {
            DataSet ds = instance(DBManager.emweb_new, CommandType.StoredProcedure, "Wap_news_GetNewsName", tool.GetSqlParameters());
            if (ds.Tables.Count > 0)
            {
                EPioneerDataModel model = new EPioneerDataModel();
                model.corSymbol = ds.Tables[0].Rows[0]["corSymbol"].ToString();
                model.hidden = ds.Tables[0].Rows[0]["hidden"].ToString();
                //model.m_lm = ds.Tables[0].Rows[0]["m_lm"].ToString();
                model.n_Abstract = ds.Tables[0].Rows[0]["n_Abstract"].ToString();
                model.n_author = ds.Tables[0].Rows[0]["n_author"].ToString();
                model.n_bigclassid = String.IsNullOrEmpty(ds.Tables[0].Rows[0]["n_bigclassid"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[0]["n_bigclassid"].ToString());
                model.n_content = ds.Tables[0].Rows[0]["n_content"].ToString();
                model.n_createdate = String.IsNullOrEmpty(ds.Tables[0].Rows[0]["n_createdate"].ToString()) ? DateTime.MinValue : Convert.ToDateTime(ds.Tables[0].Rows[0]["n_createdate"].ToString());
                model.n_enddate = String.IsNullOrEmpty(ds.Tables[0].Rows[0]["n_enddate"].ToString()) ? DateTime.MinValue : Convert.ToDateTime(ds.Tables[0].Rows[0]["n_enddate"].ToString());
                model.n_id = String.IsNullOrEmpty(ds.Tables[0].Rows[0]["n_id"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[0]["n_id"].ToString());
                model.n_Isgo = String.IsNullOrEmpty(ds.Tables[0].Rows[0]["n_Isgo"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[0]["n_Isgo"].ToString());
                model.n_ISpublic = ds.Tables[0].Rows[0]["n_ISpublic"].ToString();
                model.n_Level = String.IsNullOrEmpty(ds.Tables[0].Rows[0]["n_Level"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[0]["n_Level"].ToString());
                model.n_mark = ds.Tables[0].Rows[0]["n_mark"].ToString();
                model.n_modifyDate = String.IsNullOrEmpty(ds.Tables[0].Rows[0]["n_modifyDate"].ToString()) ? DateTime.MinValue : Convert.ToDateTime(ds.Tables[0].Rows[0]["n_modifyDate"].ToString());
                //model.n_orderby = String.IsNullOrEmpty(ds.Tables[0].Rows[0]["n_orderby"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[0]["n_orderby"].ToString());
                model.n_origin = ds.Tables[0].Rows[0]["n_origin"].ToString();
                model.n_subclassid = String.IsNullOrEmpty(ds.Tables[0].Rows[0]["n_subclassid"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[0]["n_subclassid"].ToString());
                model.n_title = ds.Tables[0].Rows[0]["n_title"].ToString();
                model.n_url = ds.Tables[0].Rows[0]["n_url"].ToString();
                model.OpMsg = "";
                model.optionContent = ds.Tables[0].Rows[0]["optionContent"].ToString();
                model.optionType = String.IsNullOrEmpty(ds.Tables[0].Rows[0]["optionType"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[0]["optionType"].ToString());
                model.userType = String.IsNullOrEmpty(ds.Tables[0].Rows[0]["userType"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[0]["userType"].ToString());
                model.ReturnValue = "0";
                list.Add(model);
            }
        }
        catch
        {
            list = null;
        }
        finally
        {
        }

        return list;
    }


    /// <summary>
    /// 
    /// </summary>
    /// <param name="type1"></param>
    /// <param name="type2"></param>
    /// <param name="type3"></param>
    /// <param name="type4"></param>
    /// <param name="type5"></param>
    /// <param name="count1"></param>
    /// <param name="count2"></param>
    /// <param name="count3"></param>
    /// <param name="count4"></param>
    /// <param name="count5"></param>
    /// <param name="sign"></param>
    /// <returns></returns>
    public DataTable GetNewsInfoById(int type1, int type2, int type3, int type4, int type5, int count1, int count2, int count3, int count4, int count5, int sign)
    {
        DataTable dt = new DataTable();
        Tools tool = new Tools();
        tool.AddSqlParameter("type1", SqlDbType.Int, type1);
        tool.AddSqlParameter("type2", SqlDbType.Int, type2);
        tool.AddSqlParameter("type3", SqlDbType.Int, type3);
        tool.AddSqlParameter("type4", SqlDbType.Int, type4);
        tool.AddSqlParameter("type5", SqlDbType.Int, type5);
        tool.AddSqlParameter("count1", SqlDbType.Int, count1);
        tool.AddSqlParameter("count2", SqlDbType.Int, count2);
        tool.AddSqlParameter("count3", SqlDbType.Int, count3);
        tool.AddSqlParameter("count4", SqlDbType.Int, count4);
        tool.AddSqlParameter("count5", SqlDbType.Int, count5);
        tool.AddSqlParameter("sign", SqlDbType.Int, sign);
        try
        {
            DataSet ds = instance(DBManager.emweb_new, CommandType.StoredProcedure, "Wap_news_GetNewsName", tool.GetSqlParameters());
            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];
            }
        }
        catch
        {
            dt = null;
        }
        finally
        {
        }

        return dt;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="strGetFields">需要返回的列</param>
    /// <param name="fldName">排序的字段名</param>
    /// <param name="PageSize">页尺寸</param>
    /// <param name="PageIndex">页码</param>
    /// <param name="doCount">返回记录总数, 非 0 值则返回 </param>
    /// <param name="OrderType">设置排序类型, 非 0 值则降序</param>
    /// <param name="strWhere">查询条件 (注意: 不要加 where)</param>
    /// <returns></returns>
    public List<EPioneerDataModel> GetNewsNamePagination(string strGetFields, string fldName, int PageSize, int PageIndex, int doCount, int OrderType, string strWhere)
    {
        List<EPioneerDataModel> list = new List<EPioneerDataModel>();
        Tools tool = new Tools();
        tool.AddSqlParameter("strGetFields", SqlDbType.VarChar, strGetFields);
        tool.AddSqlParameter("fldName", SqlDbType.VarChar, fldName);
        tool.AddSqlParameter("PageSize", SqlDbType.Int, PageSize);
        tool.AddSqlParameter("PageIndex", SqlDbType.Int, PageIndex);
        tool.AddSqlParameter("doCount", SqlDbType.Int, doCount);
        tool.AddSqlParameter("OrderType", SqlDbType.Int, OrderType);
        tool.AddSqlParameter("strWhere", SqlDbType.VarChar, strWhere);
        try
        {
            DataSet ds = instance(DBManager.emweb_new, CommandType.StoredProcedure, "Wap_news_GetNewsName_Pagination", tool.GetSqlParameters());
            if (ds.Tables.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    EPioneerDataModel model = new EPioneerDataModel();
                    model.corSymbol = ds.Tables[0].Rows[i]["corSymbol"].ToString();
                    model.hidden = ds.Tables[0].Rows[i]["hidden"].ToString();
                    //model.m_lm = ds.Tables[0].Rows[i]["m_lm"].ToString();
                    model.n_Abstract = ds.Tables[0].Rows[i]["n_Abstract"].ToString();
                    model.n_author = ds.Tables[0].Rows[i]["n_author"].ToString();
                    model.n_bigclassid = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_bigclassid"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["n_bigclassid"].ToString());
                    model.n_content = ds.Tables[0].Rows[i]["n_content"].ToString();
                    model.n_createdate = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_createdate"].ToString()) ? DateTime.MinValue : Convert.ToDateTime(ds.Tables[0].Rows[i]["n_createdate"].ToString());
                    model.n_enddate = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_enddate"].ToString()) ? DateTime.MinValue : Convert.ToDateTime(ds.Tables[0].Rows[i]["n_enddate"].ToString());
                    model.n_id = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_id"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["n_id"].ToString());
                    model.n_Isgo = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_Isgo"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["n_Isgo"].ToString());
                    model.n_ISpublic = ds.Tables[0].Rows[i]["n_ISpublic"].ToString();
                    model.n_Level = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_Level"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["n_Level"].ToString());
                    model.n_mark = ds.Tables[0].Rows[i]["n_mark"].ToString();
                    model.n_modifyDate = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_modifyDate"].ToString()) ? DateTime.MinValue : Convert.ToDateTime(ds.Tables[0].Rows[i]["n_modifyDate"].ToString());
                    //model.n_orderby = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_orderby"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["n_orderby"].ToString());
                    model.n_origin = ds.Tables[0].Rows[i]["n_origin"].ToString();
                    model.n_subclassid = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_subclassid"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["n_subclassid"].ToString());
                    model.n_title = ds.Tables[0].Rows[i]["n_title"].ToString();
                    model.n_url = ds.Tables[0].Rows[i]["n_url"].ToString();
                    model.optionContent = ds.Tables[0].Rows[i]["optionContent"].ToString();
                    model.optionType = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["optionType"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["optionType"].ToString());
                    model.userType = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["userType"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["userType"].ToString());
                    list.Add(model);
                }
            }
        }
        catch
        {
            list = null;
        }
        finally
        {
        }
        return list;
    }

    public DataSet GetNewsNamePagination(string strGetFields, string fldName, int PageSize, int PageIndex, int doCount, int OrderType, string strWhere, bool bz)
    {
        DataSet ds = new DataSet();
        Tools tool = new Tools();
        tool.AddSqlParameter("strGetFields", SqlDbType.VarChar, strGetFields);
        tool.AddSqlParameter("fldName", SqlDbType.VarChar, fldName);
        tool.AddSqlParameter("PageSize", SqlDbType.Int, PageSize);
        tool.AddSqlParameter("PageIndex", SqlDbType.Int, PageIndex);
        tool.AddSqlParameter("doCount", SqlDbType.Int, doCount);
        tool.AddSqlParameter("OrderType", SqlDbType.Int, OrderType);
        tool.AddSqlParameter("strWhere", SqlDbType.VarChar, strWhere);
        try
        {
            ds = instance(DBManager.emweb_new, CommandType.StoredProcedure, "Wap_news_GetNewsName_Pagination", tool.GetSqlParameters());
        }
        catch
        {
            ds = null;
        }
        return ds;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="strGetFields"></param>
    /// <param name="fldName"></param>
    /// <param name="PageSize"></param>
    /// <param name="PageIndex"></param>
    /// <param name="doCount"></param>
    /// <param name="OrderType"></param>
    /// <param name="strWhere"></param>
    /// <returns></returns>
    public DataModel GetDataModelPagination(string strGetFields, string fldName, int PageSize, int PageIndex, int doCount, int OrderType, string strWhere, int total)
    {
        DataModel result = new DataModel();
        List<EPioneerDataModel> list = new List<EPioneerDataModel>();
        Tools tool = new Tools();
        tool.AddSqlParameter("strGetFields", SqlDbType.VarChar, strGetFields);
        tool.AddSqlParameter("fldName", SqlDbType.VarChar, fldName);
        tool.AddSqlParameter("PageSize", SqlDbType.Int, PageSize);
        tool.AddSqlParameter("PageIndex", SqlDbType.Int, PageIndex);
        tool.AddSqlParameter("doCount", SqlDbType.Int, doCount);
        tool.AddSqlParameter("OrderType", SqlDbType.Int, OrderType);
        tool.AddSqlParameter("strWhere", SqlDbType.VarChar, strWhere);
        try
        {
            DataSet ds = instance(DBManager.emweb_new, CommandType.StoredProcedure, "Wap_news_GetNewsName_Pagination", tool.GetSqlParameters());
            if (ds.Tables.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (total > 0 && i == total)
                    {
                        break;
                    }
                    EPioneerDataModel model = new EPioneerDataModel();
                    model.corSymbol = ds.Tables[0].Rows[i]["corSymbol"].ToString();
                    model.hidden = ds.Tables[0].Rows[i]["hidden"].ToString();
                    //model.m_lm = ds.Tables[0].Rows[i]["m_lm"].ToString();
                    model.n_Abstract = ds.Tables[0].Rows[i]["n_Abstract"].ToString();
                    model.n_author = ds.Tables[0].Rows[i]["n_author"].ToString();
                    model.n_bigclassid = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_bigclassid"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["n_bigclassid"].ToString());
                    model.n_content = ds.Tables[0].Rows[i]["n_content"].ToString();
                    model.n_createdate = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_createdate"].ToString()) ? DateTime.MinValue : Convert.ToDateTime(ds.Tables[0].Rows[i]["n_createdate"].ToString());
                    model.n_enddate = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_enddate"].ToString()) ? DateTime.MinValue : Convert.ToDateTime(ds.Tables[0].Rows[i]["n_enddate"].ToString());
                    model.n_id = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_id"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["n_id"].ToString());
                    model.n_Isgo = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_Isgo"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["n_Isgo"].ToString());
                    model.n_ISpublic = ds.Tables[0].Rows[i]["n_ISpublic"].ToString();
                    model.n_Level = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_Level"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["n_Level"].ToString());
                    model.n_mark = ds.Tables[0].Rows[i]["n_mark"].ToString();
                    model.n_modifyDate = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_modifyDate"].ToString()) ? DateTime.MinValue : Convert.ToDateTime(ds.Tables[0].Rows[i]["n_modifyDate"].ToString());
                    //model.n_orderby = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_orderby"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["n_orderby"].ToString());
                    model.n_origin = ds.Tables[0].Rows[i]["n_origin"].ToString();
                    model.n_subclassid = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["n_subclassid"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["n_subclassid"].ToString());
                    model.n_title = ds.Tables[0].Rows[i]["n_title"].ToString();
                    model.n_url = ds.Tables[0].Rows[i]["n_url"].ToString();
                    model.optionContent = ds.Tables[0].Rows[i]["optionContent"].ToString();
                    model.optionType = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["optionType"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["optionType"].ToString());
                    model.userType = String.IsNullOrEmpty(ds.Tables[0].Rows[i]["userType"].ToString()) ? -1 : Convert.ToInt32(ds.Tables[0].Rows[i]["userType"].ToString());
                    list.Add(model);
                }
            }
        }
        catch
        {
            list = null;
        }

        result.Total = GetDataModelPagination(strWhere);
        if (total > 0 && result.Total > total)
        {
            result.Total = total;
        }
        result.ListModel = list;
        return result;
    }

    /// <summary>
    /// 获取可显示的EM_Web_News最新数据
    /// </summary>
    /// <param name="tyid">类型id</param>
    /// <returns></returns>
    public DataTable GetEMWebNews(string tyid)
    {
        DataTable dt = new DataTable();
        try
        {
            string sql = "select top 200 * from EM_Web_News where n_type='" + tyid + "' and isPub='1' order by n_createdate desc";
            DataSet ds = SqlHelper.ExecuteGetDataSet(DBManager.NewDMSConnstr, CommandType.Text, sql);
            if (ds.Tables.Count > 0)
                dt = ds.Tables[0];
        }
        catch
        {
            dt = null;
        }

        return dt;
    }

    /// <summary>
    /// 今日要闻精选
    /// </summary>
    /// <param name="tyid">类型</param>
    /// <param name="level">级别</param>
    /// <returns></returns>
    public DataTable GetEMWebNews(string tyid, string level)
    {
        DataTable dt = new DataTable();
        try
        {
            string sql = "select top 200 * from EM_Web_News where n_type='" + tyid + "' and n_level='" + level + "' order by n_createdate desc";
            DataSet ds = SqlHelper.ExecuteGetDataSet(DBManager.NewDMSConnstr, CommandType.Text, sql);
            if (ds.Tables.Count > 0)
                dt = ds.Tables[0];
        }
        catch
        {
            dt = null;
        }

        return dt;
    }

    public DataSet GetDataModelPagination(string strGetFields, string fldName, int PageSize, int PageIndex, int doCount, int OrderType, string strWhere, int total, bool bz)
    {
        DataSet ds = new DataSet();
        Tools tool = new Tools();
        tool.AddSqlParameter("strGetFields", SqlDbType.VarChar, strGetFields);
        tool.AddSqlParameter("fldName", SqlDbType.VarChar, fldName);
        tool.AddSqlParameter("PageSize", SqlDbType.Int, PageSize);
        tool.AddSqlParameter("PageIndex", SqlDbType.Int, PageIndex);
        tool.AddSqlParameter("doCount", SqlDbType.Int, doCount);
        tool.AddSqlParameter("OrderType", SqlDbType.Int, OrderType);
        tool.AddSqlParameter("strWhere", SqlDbType.VarChar, strWhere);
        try
        {
            ds = instance(DBManager.emweb_new, CommandType.StoredProcedure, "Wap_news_GetNewsName_Pagination", tool.GetSqlParameters());
        }
        catch
        {
            ds = null;
        }

        return ds;
    }

    /// <summary>
    /// 获取所有报表数据
    /// </summary>
    /// <returns></returns>
    public DataTable GetEMResearchReport()
    {
        DataTable dt = new DataTable();
        try
        {
            DataSet ds = instance(DBManager.NewDMSConnstr, CommandType.Text, "select * from EM_RESEARCH_REPORT");
            if (ds.Tables.Count > 0)
                dt = ds.Tables[0];
        }
        catch
        {
            dt = null;
        }

        return dt;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    public DataTable GetNEWSTEXT(string id)
    {
        DataTable dt = new DataTable();
        try
        {
            SqlParameter[] values = { new SqlParameter("@id", id) };
            DataSet ds = instance(DBManager.NewDMSConnstr, CommandType.Text, "select top 200 nt.* from dbo.NEWS_TEXT as nt left join dbo.NEWS_SORT as ns on nt.TextID=ns.TextID where ns.SortCode=@id order by nt.PublDate desc", values);
            if (ds.Tables.Count > 0)
                dt = ds.Tables[0];
        }
        catch
        {
            dt = null;
        }

        return dt;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    public DataTable GetNEWSTEXTByWhere(string strWhere)
    {
        DataTable dt = new DataTable();
        try
        {
            DataSet ds = instance(DBManager.NewDMSConnstr, CommandType.Text, "select top 200 * from NEWS_TEXT where TextID in (" + strWhere + ") order by PublDate desc");
            if (ds.Tables.Count > 0)
                dt = ds.Tables[0];
        }
        catch
        {
            dt = null;
        }

        return dt;
    }

    /// <summary>
    /// 个股异动
    /// </summary>
    /// <param name="strWhere"></param>
    /// <returns></returns>
    public DataTable GetStockAbnormalMsgWhere(string strWhere)
    {
        DataTable dt = new DataTable();
        try
        {
            return new DataTable() ;
        }
        catch
        {
            dt = null;
        }

        return dt;
    }

    /// <summary>
    /// 基础行情数据
    /// </summary>
    /// <param name="id">数据类型</param>
    /// <returns></returns>
    public DataTable GetStockAbnormalMsg(string id)
    {
        DataTable dt = new DataTable();
        try
        {
            id = id == null ? "" : id;
            id = id.Replace("'", "");
            //SqlParameter[] values = { new SqlParameter("@id", id) };
            //DataSet ds = instance(DBManager.Emoney, CommandType.Text, "select top 200 * from STOCK_ABNORMAL_MSG where stock_id=@id order by modify_time desc", values);
            StringBuilder sb=new StringBuilder();
            sb.AppendLine("select top 200 f025v_12001 stock_id,f021v_12001 stock_name,f035d_12001 abnormal_date,");
            sb.AppendLine("f006v_12001 [master],0 increase,'' last_month_rate,f011v_12001 reason,f035d_12001 case_date,");
            sb.AppendLine("f006v_12001 case_summary,f015v_12001 case_content,null cancel_date,'' major_short_reason,");
            sb.AppendLine("'' major_long_reason,'' msg_oper, '是' msg_confirm,'' 'major_oper','' major_confirm,'' affect,'' memo,modtime modify_time,");
            sb.AppendLine("newsid_num id");
            sb.AppendLine(" from");
            sb.AppendLine("vm_dms_getnewsbycode");
            sb.AppendLine("where code ='3070505' and F004V_12001=4 and f025v_12001='"+id+"' and isChecked=1 order by f053d_12001 desc");
            DataSet ds = SqlHelper.ExecuteGetDataSet(DBManager.NewDMSConnstr, CommandType.Text, sb.ToString(), null);
            if (ds.Tables.Count > 0)
                dt = ds.Tables[0];
        }
        catch
        {
            dt = null;
        }

        return dt;
    }

    /// <summary>
    /// 公司公告
    /// </summary>
    /// <returns></returns>
    public DataTable GetAnnounceTxtInfo()
    {
        DataTable dt = new DataTable();
        try
        {
            DataSet ds = instance(DBManager.NewDMSConnstr, CommandType.Text, "select top 10 * from  ANNOUNCE_TXT_INFO order by PublDate desc");
            if (ds.Tables.Count > 0)
                dt = ds.Tables[0];
        }
        catch
        {
            dt = null;
        }

        return dt;
    }

    /// <summary>
    /// 为新股日历查询解冻股票
    /// </summary>
    /// <param name="thisdate"></param>
    /// <returns></returns>
    public DataTable GetNewDate()
    {
        DataTable dt = new DataTable();
        try
        {
            DataSet ds = instance(DBManager.NewDMSConnstr, CommandType.Text, "select se.SecuCode,se.SecuAbbr,co.OLRefundDate,co.OffLRefundDate from [SECURITY] as se left join COMPANY_IPO as co on se.SecuID=co.OrgID");
            if (ds.Tables.Count > 0)
                dt = ds.Tables[0];
        }
        catch
        {
            dt = null;
        }

        return dt;
    }

    /// <summary>
    /// 查询总条数
    /// </summary>
    /// <param name="strWhere"></param>
    /// <returns></returns>
    public int GetDataModelPagination(string strWhere)
    {
        int result = 0;
        Tools tool = new Tools();
        tool.AddSqlParameter("strGetFields", SqlDbType.VarChar, "");
        tool.AddSqlParameter("fldName", SqlDbType.VarChar, "");
        tool.AddSqlParameter("PageSize", SqlDbType.Int, 0);
        tool.AddSqlParameter("PageIndex", SqlDbType.Int, 0);
        tool.AddSqlParameter("doCount", SqlDbType.Int, 1);
        tool.AddSqlParameter("OrderType", SqlDbType.Int, 0);
        tool.AddSqlParameter("strWhere", SqlDbType.VarChar, strWhere);
        try
        {
            DataSet ds = instance(DBManager.emweb_new, CommandType.StoredProcedure, "Wap_news_GetNewsName_Pagination", tool.GetSqlParameters());
            if (ds.Tables.Count > 0)
            {
                result = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            }
        }
        catch
        {
            result = 0;
        }
        return result;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="strGetFields">需要返回的列</param>
    /// <param name="fldName">排序的字段名</param>
    /// <param name="PageSize">页尺寸</param>
    /// <param name="PageIndex">页码</param>
    /// <param name="doCount">返回记录总数, 非 0 值则返回 </param>
    /// <param name="OrderType">设置排序类型, 非 0 值则降序</param>
    /// <param name="strWhere">查询条件 (注意: 不要加 where)</param>
    /// <returns></returns>
    public DataTable GetNewsInfoPagination(string strGetFields, string fldName, int PageSize, int PageIndex, int doCount, int OrderType, string strWhere)
    {
        DataTable dt = new DataTable();
        Tools tool = new Tools();
        tool.AddSqlParameter("strGetFields", SqlDbType.VarChar, strGetFields);
        tool.AddSqlParameter("fldName", SqlDbType.VarChar, fldName);
        tool.AddSqlParameter("PageSize", SqlDbType.Int, PageSize);
        tool.AddSqlParameter("PageIndex", SqlDbType.Int, PageIndex);
        tool.AddSqlParameter("doCount", SqlDbType.Int, doCount);
        tool.AddSqlParameter("OrderType", SqlDbType.Int, OrderType);
        tool.AddSqlParameter("strWhere", SqlDbType.VarChar, strWhere);
        try
        {
            DataSet ds = instance(DBManager.emweb_new, CommandType.StoredProcedure, "Wap_news_GetNewsName_Pagination", tool.GetSqlParameters());
            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];
            }
        }
        catch
        {
            dt = null;
        }
        return dt;
    }
}